package com.example.friend.controller.question;

import com.example.common.core.controller.BaseController;
import com.example.common.core.domain.Result;
import com.example.common.core.domain.TableDataInfo;
import com.example.common.core.enums.ResultCode;
import com.example.friend.domain.question.dto.QuestionQueryDTO;
import com.example.friend.domain.question.vo.QuestionDetailVO;
import com.example.friend.service.question.QuestionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 23050
 * @version 1.0
 * @description: TODO
 * @date 2025/3/16 20:30
 */
@RestController
@RequestMapping("/question")
public class QuestionController extends BaseController {



    @Resource
    private QuestionService questionService;

    /**
     * @author 23050
     * @description:  从Redis中获取题目列表
     * @date: 2025/3/26 22:58
     * @param questionQueryDTO
     * @return com.example.common.core.domain.TableDataInfo
     */
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO){

        return questionService.list(questionQueryDTO);
    }

    /**
     * @author 23050
     * @description:  获取题目详情
     * @date: 2025/3/26 22:58
     * @param questionId
     * @return com.example.common.core.domain.Result
     */
    @GetMapping("/detail")
    public Result detail(Long questionId){
        QuestionDetailVO questionDetailVO = questionService.detail(questionId);
        return new Result(ResultCode.SUCCESS.getCode(),"success",questionDetailVO);
    }


    /**
     * @author 23050
     * @description:  上一题
     * @date: 2025/3/27 19:41
     * @return com.example.common.core.domain.Result
     * 在Redis中找    question:list  [questionId]
     *
     */
    @GetMapping("/preQuestion")
    public Result preQuestion(Long questionId){
        return new Result(ResultCode.SUCCESS.getCode(),"success",questionService.preQuestion(questionId));
    }


    /**
     * @author 23050
     * @description:  下一题
     * @date: 2025/3/27 19:41
     * @return com.example.common.core.domain.Result
     */
    @GetMapping("/nextQuestion")
    public Result nextQuestion(Long questionId){
        return new Result(ResultCode.SUCCESS.getCode(),"success",questionService.nextQuestion(questionId));
    }








}
